<?php
namespace Home\Controller;
use Think\Controller;


/**
* 前台登录
*/
class SignupController extends Controller
{
	public function index()
	{
		$this->assign('vcode', $vcode);
		$this->display('Signup/index');
	
	}
	public function Verify()
	{
		$Verify = new \Think\Verify();
		$Verify->entry();
	}

	public function add()
	{
	    $this->assign('title','添加用户');
	    $this->display('User/add');
	}

	public function signup()
	{	
		if (empty($_POST['name'] && $_POST['password'] && $_POST['mail'])) 
		{		
				
			$this->redirect('Home/signup/index');
			exit;
		} else {
			$this->assign('title','添加用户');
			$this->display('Home/signup/add');
		}

	}
	//执行添加
	public function insert()
	{
	    //判断 有无传递POST
	    $pwd =md5($_POST['pwd']);
	    // echo $pwd;
	    $_POST['pwd'] = $pwd;
	    // var_dump($_POST);
	    // exit;
	    if (empty($_POST['uname'] && $_POST['pwd'] && $_POST['email'])) {
	        $this->error('请完善表单数据!',U('Home/signup/index'));
	        exit;
	    }
	    //过滤数据
	    M('user')->create();

	    if (M('user')->add() > 0) {
	        $this->success('添加成功',U('Home/login/index'));
	    } else {
	        $this->error('添加失败');
	    }
	}

}